# Read in the CA county data (TIGER shapefile):
ca_counties <- read_sf(here("data", "ca_counties"), layer = "CA_Counties_TIGER2016") %>%
clean_names() %>%
dplyr::select(name)
# Read in the oil spill data (ds394 shapefile):
oil_spill <- read_sf(here("data", "ds394"), layer = "ds394") %>%
clean_names()
# Check the projections
st_crs(ca_counties) # WGS84
st_crs(oil_spill) # NAD83
# Transform CA counties to match oil spill data CRS
ca_counties <- st_transform(ca_counties, st_crs(oil_spill))
st_crs(ca_counties) # NAD83
# Create a graph to explore the data
ggplot() +
geom_sf(data = ca_counties) +
geom_sf(data = oil_spill)
# Exploratory interactive map showing the location of oil spill events
tmap_mode("view")
tm_shape(ca_counties) +
tm_polygons() +
tm_shape(oil_spill) +
tm_dots()